<template>
	<view class="box">
		<view v-for="(item, index) in dataList" :key="item.id" :data-id="item.id" :data-name='item.name' class="details" @tap="businessDetails">
			<view class="detailsImg">
				<image v-if='item.listimage' :src="`data:image/jpeg;base64,`+item.listimage" mode=""></image>
			</view>
			<view class="detailsinfo">
				<view class="title">{{ item.name }}</view>
				<view class="count">{{ item.listdesc }}</view>
				<view class="time">
					{{ item.create_date }}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.baseUrl,
				articleUrl :'https://www.1xx.online/japx/article',
				reqtype:'',
				reqname:'',
				dataList :[],
			}
		},
		
		onLoad(options) {
			var that = this
			that.reqtype = options.type;
			that.reqname = options.title;
			uni.setNavigationBarTitle({
				title:options.title,
			})
			this.initDataList()
		},
		methods: {
			initDataList(){
				var that = this
				uni.request({
					url: that.articleUrl,
					data: JSON.stringify({ params: { 'category':that.reqtype,'pubstatus':'active'},jsonrpc:'2.0',id:Number(new Date()) }),
					header: {
						'Content-Type': 'application/json'
					},
					method: 'POST',
					dataType: 'json',
					complete: res => {
						if (res.statusCode == 200) {
							var result = res.data.result
							if (!!result) {
								that.dataList = [];
								for (var i = 0; i < result.length; i++) {
									that.dataList.push(result[i]);
								}
							}
						}
					}
				})
			},
			businessDetails(e) {
				var headid = e.currentTarget.dataset['id'];
				var name = e.currentTarget.dataset["name"]
				var newpage = '/pages/information/detail?headid=' + headid+'&name=' + name
				uni.navigateTo({
					url: newpage,
					text: name
				});
			}
			
		}
	};
</script>

<style>
	.box{
		width: 100%;
	}
	.details{
		height: auto;
		padding: 24rpx;
		display: flex;
		justify-content: space-between;
		margin-bottom: 20rpx;
	}
	.detailsImg image{
		width: 300rpx;
		height: 200rpx;
	}
	.detailsinfo{
		margin-left: 20rpx;
	}
	.count{
		text-indent: 30rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 3;
		overflow: hidden;
		font-size: 24rpx;
		color: #666666;
	}
	.title{
		font-size: 28rpx;
		color: #030303;
		margin-bottom: 22rpx;
	}
	.time{
		margin-top: 22rpx;
		font-size: 20rpx;
		color: #666666;
		float: right;
	}
</style>
